<?php
/**
 * +--------------------------------------------------------+
 * @Created by PhpStorm.
 * @Category CategoryStoreRequest.php
 * @Depiction:
 * Author: hwy
 * Date: 2021/2/22  17:16
 * +--------------------------------------------------------+
 */

namespace App\Http\Requests;


class CategoryUpdateRequest extends BaseRequestsPost
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'  => 'required|unique:category,name,' . $this->get('id') . ',id',
            'order' => 'required',
        ];
    }

    /**
     * 定义字段名中文
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'name'  => '名称',
            'order' => '排序',
        ];
    }

    public function messages()
    {
        return [
            'name.required'  => '名称不能为空',
            'name.unique'    => '名称已存在',
            'order.required' => '排序不能为空',
        ];
    }

}
